import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, IBooking } from "./types";
import { ILabVO } from "../lab/types";

/* 查询预约记录列表 */
export function getPageBookingAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<IBooking[]>> {
  return request({
    url: "/booking/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询预约记录对象 */
export function getFormBookingAPI(id: number): AxiosPromise<IBooking> {
  return request({
    url: `/booking/${id}/form`,
    method: "get",
  });
}

/**
 * 添加预约记录
 *
 * @param data
 */
export function addBookingAPI(data: any) {
  return request({
    url: "/booking",
    method: "post",
    data: data,
  });
}

/**
 * 修改预约记录
 *
 * @param id
 * @param data
 */
export function updateBookingAPI(id: number, data: IBooking) {
  return request({
    url: "/booking/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除预约记录
 *
 * @param ids
 */
export function deleteBookingAPI(ids: number) {
  return request({
    url: "/booking/" + ids,
    method: "delete",
  });
}

/* 查询实验室列表列表 */
export function getLabListAPI(): AxiosPromise<PageResult<ILabVO[]>> {
  return request({
    url: "/laboratory/cascader",
    method: "get",
  });
}

/* 获取预约申请 */
export function getPageBookingApplicationAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<IBooking[]>> {
  return request({
    url: "/booking/application/page",
    method: "get",
    params: queryParams,
  });
}

export function overruleAPI(data: IBooking) {
  return request({
    url: "/booking/overrule",
    method: "put",
    data: data,
  });
}

export function passAPI(id: number) {
  return request({
    url: "/booking/pass/" + id,
    method: "get",
  });
}

export function cancelAPI(id: number) {
  return request({
    url: "/booking/cancel/" + id,
    method: "get",
  });
}

export function finishAPI(id: number) {
  return request({
    url: "/booking/finish/" + id,
    method: "get",
  });
}
